<template>
	<view class="index">
		<view style="height: 250rpx; background: #1365f9">
			<u-navbar bgColor="rgba(0,0,0,0)" :fixed="false">
				<view slot="left" class="align-center">
					<view
						class="text1"
						:class="{ text2: current == 0 }"
						@click="
							list = [];
							current = 0;
							getlist();
						"
					>
						公司简历池
					</view>
					<view
						class="text1"
						:class="{ text2: current == 1 }"
						@click="
							list = [];
							current = 1;
							getlist();
						"
						style="margin-left: 60rpx"
					>
						我的简历池
					</view>
				</view>
			</u-navbar>
		</view>
		<view class="flex-center1" style="position: relative; top: -60rpx">
			<view style="width: 686rpx; height: 116rpx; padding: 38rpx 44rpx; background: #ffffff; border-radius: 16rpx">
				<view class="align-center">
					<!-- <text style="font-weight: 400; font-size: 28rpx; color: #666666; margin-right: 18rpx">全部岗位</text>
					<u-icon name="arrow-down" :bold="true" size="22"></u-icon>
					<text style="font-weight: 400; font-size: 28rpx; color: #666666; margin-left: 28rpx; margin-right: 26rpx">|</text> -->
					<view class="flex-between1" style="flex: 1">
						<input
							type="text"
							v-model="name"
							@confirm="
								list = [];
								getlist();
							"
							placeholder="搜索劳动者、简历"
							style="font-weight: 400; font-size: 28rpx; color: #666666; flex: 1"
						/>
						<u-icon name="search" color="#666666" size="43"></u-icon>
					</view>
				</view>
			</view>
		</view>
		<view class="flex-between1" style="padding: 0 32rpx 30rpx">
			<view style="font-weight: 600; font-size: 36rpx; color: #333333">劳动者报名</view>
			<view class="flex">
				<view @click="addressShow = true" class="flex-center1" style="margin-right: 20rpx; width: 120rpx; height: 52rpx; background: #edf2f9; border-radius: 4rpx">
					<text style="margin-right: 22rpx">{{ address }}</text>
					<image src="@/static/index/bottom@2x.png" style="width: 22rpx; height: 14rpx"></image>
				</view>
				<address-picker
					:show="addressShow"
					closeOnClickOverlay
					@confirm="confirmAddress"
					@cancel="addressShow = false"
					@close="addressShow = false"
					:address-data="addressData"
					:indexs="indexs"
					:areaId="areaId"
					:type="areatype"
				></address-picker>
				<view
					@click="$tools.navigite('/pages/index/postjob')"
					class="flex-center1"
					style="margin-right: 20rpx; width: 120rpx; height: 52rpx; background: #edf2f9; border-radius: 4rpx"
				>
					<text style="margin-right: 22rpx">工种</text>
					<image src="@/static/index/bottom@2x.png" style="width: 22rpx; height: 14rpx"></image>
				</view>
				<view
					@click="$tools.navigite('/pages1/index/screen')"
					class="flex-center1"
					style="margin-right: 20rpx; width: 120rpx; height: 52rpx; background: #edf2f9; border-radius: 4rpx"
				>
					<text style="margin-right: 22rpx">筛选</text>
					<image src="@/static/index/bottom@2x.png" style="width: 22rpx; height: 14rpx"></image>
				</view>
			</view>
		</view>
		<view style="padding: 0 32rpx" v-if="current == 0">
			<view
				class="flex"
				@click.stop.native="$tools.navigite('./jianli', 1, item.userId, item.id, 1)"
				v-for="(item, index) in list"
				:key="index"
				style="padding: 20rpx; background-color: #fff; margin-bottom: 20rpx; position: relative"
			>
				<view style="margin-right: 28rpx"></view>
				<view style="flex: 1">
					<view class="flex-between1">
						<view class="align-center">
							<view style="margin-right: 20rpx">
								<image :src="item.userInfo.head" style="width: 84rpx; height: 84rpx" mode="aspectFill"></image>
							</view>
							<view class="">
								<view class="align-center">
									<view style="font-weight: 600; font-size: 32rpx; color: #333333">{{ item.userInfo.name }}</view>
									<u-icon v-if="current == 1" name="file-text" color="#1365F9" size="44"></u-icon>
								</view>
								<view style="font-weight: 300; font-size: 24rpx; color: #999999; padding: 14rpx 0">
									{{ item.userInfo.sex == 1 ? '男' : '女' }} | {{ item.userInfo.age }}岁
								</view>
							</view>
						</view>
						<view class="align-center">
							<view
								@click="$tools.playphone(item.userInfo.phone)"
								class="flex-center1"
								style="margin-right: 20rpx; width: 56rpx; height: 56rpx; background: #1365f9; border-radius: 8rpx"
							>
								<u-icon name="phone-fill" color="#fff" size="40"></u-icon>
							</view>
						</view>
					</view>
					<view style="font-weight: 600; font-size: 32rpx; color: #333333; padding: 14rpx 0">
						{{ item.postInfo.jobName }}/{{ item.postInfo.salaryStart }}-{{ item.postInfo.salaryEnd }}
					</view>
					<view class="flex-wrap">
						<view style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666">
							{{ item.userInfo.workIntention }}
						</view>
						<view style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666">
							{{ item.userInfo.income }}
						</view>
						<view style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666">
							{{ item.userInfo.workTime }}
						</view>
						<view style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666">
							{{ item.userInfo.workAddress }}
						</view>
					</view>
					<view style="font-weight: 400; font-size: 24rpx; color: #333333">{{ item.userInfo.remark }}</view>
				</view>
				<!-- <view style="position: absolute; top: 0; left: 0">
					<image src="@/static/index/close.png" style="width: 40rpx; height: 40rpx"></image>
				</view> -->
			</view>

			<view v-if="!list.length" style="text-align: center; padding-top: 100rpx">暂无数据~</view>
		</view>
		<view v-if="current == 1">
			<view class="flex-between1" style="background: #ffffff; padding: 24rpx 30rpx; margin-bottom: 20rpx">
				<view
					class="text3"
					:class="{ text4: type == 0 }"
					@click="
						type = 0;
						list = [];
						getlist();
					"
				>
					全部
				</view>
				<view
					class="text3"
					:class="{ text4: type == 1 }"
					@click="
						type = 1;
						list = [];
						getlist();
					"
				>
					筛选中
				</view>
				<view
					class="text3"
					:class="{ text4: type == 2 }"
					@click="
						type = 2;
						list = [];
						getlist();
					"
				>
					合适
				</view>
				<view
					class="text3"
					:class="{ text4: type == 3 }"
					@click="
						type = 3;
						list = [];
						getlist();
					"
				>
					不合适
				</view>
			</view>
			<view style="padding: 0 32rpx">
				<view
					class="flex"
					@click.stop.native="$tools.navigite('./jianli', 1, item.userId, item.id, item.status)"
					v-for="(item, index) in list"
					:key="index"
					style="position: relative; padding: 20rpx; background-color: #fff; margin-bottom: 20rpx"
				>
					<view style="margin-right: 28rpx">
						<image :src="item.userInfo.head" style="width: 196rpx; height: 240rpx" mode="aspectFill"></image>
					</view>
					<view style="flex: 1">
						<view class="flex-between1">
							<view class="align-center">
								<view style="font-weight: 600; font-size: 32rpx; color: #333333">{{ item.userInfo.name }}</view>
								<u-icon name="file-text" color="#1365F9" size="44"></u-icon>
							</view>
							<view class="align-center">
								<view
									@click="$tools.playphone(item.userInfo.phone)"
									class="flex-center1"
									style="margin-right: 20rpx; width: 56rpx; height: 56rpx; background: #1365f9; border-radius: 8rpx"
								>
									<u-icon name="phone-fill" color="#fff" size="40"></u-icon>
								</view>
							</view>
						</view>
						<view style="font-weight: 300; font-size: 24rpx; color: #999999; padding: 14rpx 0">
							{{ item.postInfo.jobName }}/{{ item.postInfo.salaryStart }}-{{ item.postInfo.salaryEnd }}
						</view>
						<view class="flex-wrap">
							<view
								style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666"
							>
								{{ item.userInfo.workIntention }}
							</view>
							<view
								style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666"
							>
								{{ item.userInfo.income }}
							</view>
							<view
								style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666"
							>
								{{ item.userInfo.workTime }}
							</view>
							<view
								style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666"
							>
								{{ item.userInfo.workAddress }}
							</view>
						</view>
						<view style="font-weight: 400; font-size: 24rpx; color: #333333; margin-bottom: 20rpx">{{ item.userInfo.remark }}</view>
						<view class="flex" v-if="item.status == 0">
							<view
								@click.native.stop="handleSign(1, item.id)"
								class="flex-center1"
								style="margin-right: 20rpx; font-size: 24rpx; color: #ffffff; width: 100rpx; height: 56rpx; background: #1365f9; border-radius: 8rpx"
							>
								合适
							</view>
							<view
								@click.native.stop="handleSign(2, item.id)"
								class="flex-center1"
								style="margin-right: 20rpx; font-size: 24rpx; color: #ffffff; width: 126rpx; height: 56rpx; background: #fe4343; border-radius: 8rpx"
							>
								不合适
							</view>
							<!-- <view
								class="flex-center1"
								style="margin-right: 20rpx; font-size: 24rpx; color: #ffffff; width: 156rpx; height: 56rpx; background: #1365f9; border-radius: 8rpx"
							>
								安排住宿
							</view> -->
						</view>
					</view>
					<view style="position: absolute; right: 20rpx; bottom: 40rpx">
						<image v-if="item.status == 1" src="@/static/fuwu/hs1.png" style="width: 124rpx; height: 108rpx"></image>
						<image v-if="item.status == 2" src="@/static/fuwu/hs2.png" style="width: 124rpx; height: 108rpx"></image>
					</view>
				</view>

				<view v-if="!list.length" style="text-align: center; padding-top: 100rpx">暂无数据~</view>
			</view>
		</view>
		<Tabbar1 :value="0" />
	</view>
</template>

<script>
export default {
	data() {
		return {
			address: '城市',
			addressShow: false,
			indexs: [0, 0, 0],
			areaId: [-1, -1, 110101],
			addressData: ['不限', '不限', '东城区'],
			areatype: 2, //1-省，2-省市，3-省市区
			area: '', //区域id
			current: 0,
			type: 0,
			pageNum: 1,
			pageSize: 20,
			isLastPage: false,
			list: [],
			name: '',
			jobType: [], //岗位类型
			ageStart: '',
			ageEnd: '',
			culture: '',
			startIncome: '',
			sex: ''
		};
	},
	async onShow() {
		await this.getsf();
		await this.init();
	},
	onReachBottom() {
		if (this.isLastPage) return;
		this.pageNum++;
		this.getlist();
	},
	methods: {
		init() {
			this.list = [];
			this.getlist();
		},
		getlist() {
			if (this.current == 0) {
				const data = {
					name: this.name,
					pageNum: this.pageNum,
					pageSize: this.pageSize,
					area: this.area == -1 ? '' : this.area,
					jobType: this.jobType,
					ageStart: this.ageStart == '不限' ? '' : this.ageStart,
					ageEnd: this.ageEnd == '不限' ? '' : this.ageEnd,
					culture: this.culture ? this.culture : '',
					startIncome: this.startIncome ? this.startIncome : '',
					sex: this.sex
				};
				this.$request('front/company/publicResume', data).then((res) => {
					this.list = [...this.list, ...res.obj.list];
					console.log(res.obj.list, '列表');
					this.isLastPage = res.obj.isLastPage;
				});
			} else {
				const data = {
					name: this.name,
					pageNum: this.pageNum,
					pageSize: this.pageSize,
					status: this.type - 1
				};
				this.$request('front/company/myResume', data).then((res) => {
					this.list = [...this.list, ...res.obj.list];
					console.log(res.obj.list, '列表');
					this.isLastPage = res.obj.isLastPage;
				});
			}
		},

		getsf() {
			this.$request('front/user/getUserRole', { type: 1 }).then((res) => {
				console.log(res.obj, 'res.obj');
				if (!res.obj) {
					this.$tools.navigite('./gsxx');
				}
			});
		},
		confirmAddress(val) {
			console.log(val);
			this.address = val.value[1];
			this.area = val.areaId[1];
			this.addressShow = false;
			this.list = [];
			this.getlist();
		},
		handleSign(status, id) {
			const data = {
				id,
				status
			};
			this.$request('front/company/handleSign', data).then((res) => {
				console.log(res, 'res');
				this.$tools.toast('操作成功');
				setTimeout(() => {
					this.init();
				}, 1000);
			});
		},
		cccc() {
			console.log(111);
		}
	}
};
</script>

<style lang="less" scoped>
.index {
	min-height: 100vh;
	background: #f5f6fa;
	.text1 {
		font-weight: 400;
		font-size: 28rpx;
		color: #ffffff;
	}
	.text2 {
		font-weight: 600;
		font-size: 48rpx;
		color: #ffffff;
	}
	.text3 {
		font-weight: 400;
		font-size: 28rpx;
		color: #999999;
	}
	.text4 {
		font-weight: 600;
		font-size: 28rpx;
		color: #1365f9;
	}
}
</style>
